package ru.reaperoq.inventory

import android.annotation.SuppressLint
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color

val verifiedColors = listOf(
    Color.Green.copy(alpha = 0.5f),
    Color.Green,
    Color.Green.copy(alpha = 0.5f),
)

val unverifiedColors = listOf(
    Color.Red.copy(alpha = 0.5f),
    Color.Red,
    Color.Red.copy(alpha = 0.5f),
)

val loadingColors = listOf(
    Color.Gray.copy(alpha = 0.5f),
    Color.Gray,
    Color.Gray.copy(alpha = 0.5f),
)

@SuppressLint("UnnecessaryComposedModifier")
fun Modifier.verificationShimmer(colors: List<Color>): Modifier = composed {
    val transition = rememberInfiniteTransition(label = "backgroundShimmer")

    val animation = transition.animateFloat(
        initialValue = 0f,
        targetValue = 3000f,
        animationSpec = infiniteRepeatable(
            tween(1500), RepeatMode.Reverse
        ),
        label = ""
    )

    this.background(
        brush = Brush.linearGradient(
            colors = colors,
            start = Offset.Zero,
            end = Offset(animation.value, animation.value),
        )
    )
}